package com.partyjoin.project.module.prepareEvolve.controller;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.partyjoin.common.constant.Constants;
import com.partyjoin.common.utils.DateUtils;
import com.partyjoin.common.utils.security.ShiroUtils;
import com.partyjoin.framework.aspectj.lang.annotation.Log;
import com.partyjoin.framework.aspectj.lang.constant.BusinessType;
import com.partyjoin.project.module.conference.domain.Conference;
import com.partyjoin.project.module.conference.service.IConferenceService;
import com.partyjoin.project.module.developmentEvolve.domain.DevelopmentEvolve;
import com.partyjoin.project.module.prepareEvolve.domain.PrepareEvolve;
import com.partyjoin.project.module.prepareEvolve.service.IPrepareEvolveService;
import com.partyjoin.project.module.proposer.domain.Proposer;
import com.partyjoin.project.module.proposer.service.IProposerService;
import com.partyjoin.project.system.role.domain.Role;
import com.partyjoin.project.system.role.service.IRoleService;
import com.partyjoin.project.system.user.domain.User;
import com.partyjoin.project.system.user.service.IUserService;
import com.partyjoin.framework.web.controller.BaseController;
import com.partyjoin.framework.web.page.TableDataInfo;
import com.partyjoin.framework.web.domain.AjaxResult;

/**
 * 发展预备党员记录 信息操作处理
 * 
 * @author 莫东林
 * @date 2018-07-19
 */
@Controller
@RequestMapping("/module/prepareEvolve")
public class PrepareEvolveController extends BaseController
{
    private String prefix = "module/prepareEvolve";
	
	@Autowired
	private IPrepareEvolveService prepareEvolveService;
	@Autowired
	private IUserService userService;
	@Autowired
	private IRoleService roleService;
	@Autowired
	private IConferenceService conferenceService;
	@Autowired
	private IProposerService proposerService;
	
	@RequiresPermissions("module:prepareEvolve:view")
	@GetMapping()
	public String prepareEvolve()
	{
	    return prefix + "/prepareEvolve";
	}
	
	/**
	 * 用户上级审核备案时动态获取成员材料
	 * @param userId
	 * @return
	 */
	@PostMapping("/selectUserById")
	@ResponseBody
	public User selectUserById(@RequestParam(name = "userId", required = true) String userId){
		User user = userService.selectProposer(Long.parseLong(userId));
		return user;
	}
	
	/**
	 * 获取添加党委会议时根据所选备案记录获取对象以供决议
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@GetMapping("selectUserByPrepareEvolveId")
	@ResponseBody
	public Object selectUserByPrepareEvolveId(@RequestParam(value="type") String type, PrepareEvolve prepareEvolve){
		List<User> userList = new ArrayList<User>();//待加工集合
		prepareEvolve = prepareEvolveService.selectPrepareEvolveById(prepareEvolve.getPrepareEvolveId());
		//获取发展记录需要备案的预备党员
		String[] prepareList = prepareEvolve.getPrepareList().split(",");
		//查询每个预备党员详细信息
		for(String userId : prepareList){
			User user = userService.selectUserById(Long.parseLong(userId));
			//放进需要加工的用户集合
			userList.add(user);
		}
    	List<Map<String, Object>> userLists = new ArrayList<Map<String, Object>>();//返回前端渲染下拉框
    	//为未通过下拉框添加一个无的选项
    	if(type.equals("fail")){
    		Map<String, Object> failInfo = new HashMap<String, Object>();
    		failInfo.put("id", "999");
    		failInfo.put("name", "无");
    		userLists.add(failInfo);
    	}
    	for(User u : userList){
    		Map<String, Object> info = new HashMap<String, Object>();
    		info.put("id", u.getUserId());
    		info.put("name", u.getUserName());
    		info.put("idCardNo", u.getIdCardNo());
    		info.put("remark", u.getRemark());
    		userLists.add(info);
    	}
    	return userLists;
	}
	
	/**
     * 获取党委会议所需的预备党员培养记录
     */
    @RequiresPermissions("module:prepareEvolve:list")
    @GetMapping("/selectPrepareEvolveToConference")
    @ResponseBody
    public Object selectPrepareEvolveToConference(PrepareEvolve prepareEvolve){

    	prepareEvolve.setDeptId(ShiroUtils.getUserDeptId());
    	List<PrepareEvolve> pList = prepareEvolveService.selectPrepareEvolveToConference(prepareEvolve);
    	List<Map<String, Object>> pLists = new ArrayList<Map<String, Object>>();
    	for(PrepareEvolve p : pList){
    		Map<String, Object> info = new HashMap<String, Object>();
    		info.put("id", p.getPrepareEvolveId());
    		Conference c = conferenceService.selectConferenceById(p.getConferenceIdSecond());
    		info.put("name", c.getConferenceName());
    		info.put("remark", p.getRemark());
    		pLists.add(info);
    	}
    	return pLists;
    }
	
	/**
	 * 打开上级备案审核详情
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@GetMapping("/records/details")
	public String recordDetails(PrepareEvolve prepareEvolve, Model model){
		prepareEvolve = prepareEvolveService.selectPrepareEvolveById(prepareEvolve.getPrepareEvolveId());
		Conference cFirst = conferenceService.selectConferenceById(prepareEvolve.getConferenceIdFirst());
		Conference cSecond = conferenceService.selectConferenceById(prepareEvolve.getConferenceIdFirst());
		prepareEvolve.setConferenceFirst(cFirst);
		prepareEvolve.setConferenceSecond(cSecond);
		List<User> recordUserList = new ArrayList<User>();//存放备案名单
		List<User> recordPassUserList = new ArrayList<User>();//存放备案通过名单
		List<User> recordNotPassUserList = new ArrayList<User>();//存放备案未通过名单
		User u = null;//用于开页展示
		if(prepareEvolve.getPrepareList() != null){
			String[] userList = prepareEvolve.getPrepareList().split(",");
			u = userService.selectProposer(Long.parseLong(userList[0]));
			for(String id : userList){
				User user = userService.selectUserById(Long.parseLong(id));
				recordUserList.add(user);
			}
		}
		if(prepareEvolve.getSuccessList() != null){
			String[] passList = prepareEvolve.getSuccessList().split(",");
			for(String id : passList){
				User user = userService.selectUserById(Long.parseLong(id));
				recordPassUserList.add(user);
			}
		}else{
			recordPassUserList = null;
		}
		if(prepareEvolve.getFailList() != null){
			String[] notPassList = prepareEvolve.getFailList().split(",");
			for(String id : notPassList){
				User user = userService.selectUserById(Long.parseLong(id));
				recordNotPassUserList.add(user);
			}
		}else{
			recordNotPassUserList = null;
		}
		model.addAttribute("user", u);
		model.addAttribute("recordUserList", recordUserList);
		model.addAttribute("recordPassUserList", recordPassUserList);
		model.addAttribute("recordNotPassUserList", recordNotPassUserList);
		model.addAttribute("prepareEvolve", prepareEvolve);
		System.out.println(recordPassUserList);
		System.out.println(recordNotPassUserList);
		return prefix + "/recordsDetails";
	}
	
	/**
	 * 上级预审信息列表
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@PostMapping("/records/lists")
	@ResponseBody
	public TableDataInfo recordsLists(PrepareEvolve prepareEvolve){
		startPage();
		List<PrepareEvolve> pList = new ArrayList<PrepareEvolve>();//用于返回
		//根据登陆用户查询其部门及其子部门备案记录
		if(prepareEvolve.getDeptId() == null){
			prepareEvolve.setDeptId(ShiroUtils.getUserDeptId());
		}
		List<PrepareEvolve> list = prepareEvolveService.selectPrepareEvolveList(prepareEvolve);
		for(PrepareEvolve p : list){
			if(p.getExamineState() == 1){
				pList.add(p);
			}
		}
		pList = idToNameList(pList);
		return getDataTable(pList);
	}
	
	/**
	 * 打开上级预备党员备案管理界面
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@GetMapping("/recordList")
	public String recordList(Model model){
		//获取登陆用户判断管理员角色，若是支部管理员，则无权进行备案操作，只能等待备案
		User user = userService.selectProposer(ShiroUtils.getUserId());
		model.addAttribute("user", user);
		return prefix + "/recordList";
	}
	
	/**
	 * 备案下拉获取通过的预审记录(最后组装返回预审通过的会议)
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@GetMapping("/selectPassExamine")
	@ResponseBody
	public Object selectPassExamine(PrepareEvolve prepareEvolve){
		prepareEvolve.setDeptId(ShiroUtils.getUserDeptId());
		List<PrepareEvolve> pList = prepareEvolveService.selectPassExamine(prepareEvolve);
		Map<String, Object> list = new HashMap<String, Object>();//返回数据格式
		List<Object> array = new ArrayList<Object>();//返回具体数据
		list.put("message", "");
		list.put("code", 200);
		list.put("redirect", "");
		//根据预审记录获取其预审会议信息
		if(null != pList){
			for(PrepareEvolve p : pList){
				Map<String, Object> info = new HashMap<String, Object>();
				Conference cc = conferenceService.selectConferenceById(p.getConferenceIdFirst());
				info.put("conferenceId", cc.getConferenceId());
				info.put("conferenceName", cc.getConferenceName());
				info.put("时间", cc.getConferenceTime());
				info.put("prepareEvolveId", p.getPrepareEvolveId());
				info.put("备注", "呵呵呵呵");
				array.add(info);
			}
		}
		list.put("value", array);
		return list;
	}
	
	/**
	 * 保存预审决议名单
	 */
	@RequiresPermissions("module:prepareEvolve:edit")
	@PostMapping("/saveExamineUserList")
	@ResponseBody
	public AjaxResult saveExamineUserList(PrepareEvolve prepareEvolve){
		User user = ShiroUtils.getUser();
		String[] userIds = prepareEvolve.getExamineSuccess().split(",");//通过预审ID集合
		PrepareEvolve prepareEvolves = prepareEvolveService.selectPrepareEvolveById(prepareEvolve.getPrepareEvolveId());
		//给通过预审的对象在proposer更新预审状态
		if(userIds != null && userIds.length > 0 && !userIds[0].equals("")){
			for(String userId : userIds){
				User users = userService.selectUserById(Long.parseLong(userId));
				Proposer update = proposerService.selectProposerById(users.getUserId());
				update.setExamineState(1);
				proposerService.updateProposer(update);
			}
		}
		prepareEvolves.setExamineSuccess(prepareEvolve.getExamineSuccess());
		prepareEvolves.setExamineFail(prepareEvolve.getExamineFail());
		prepareEvolves.setExamineDisposeTime(DateUtils.getNowDate());
		prepareEvolves.setExamineState(1);
		prepareEvolves.setUpdateBy(user.getUserName());
		prepareEvolves.setUpdateTime(DateUtils.getNowDate());
		if(prepareEvolveService.updatePrepareEvolve(prepareEvolves) > 0){
			Conference c = conferenceService.selectConferenceById(prepareEvolves.getConferenceIdFirst());
			c.setState(2);
			if(conferenceService.updateConference(c) > 0){
				return success();
			}else{
				return error();
			}
		}else{
			return error();
		}
	}
	
	/**
	 * 根据培养记录编号获取备案成员列表
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@PostMapping("getExamineUserList")
	@ResponseBody
	public TableDataInfo getExamineUserList(@RequestParam(name = "id") Integer prepareEvolveId){
		PrepareEvolve prepareEvolve = prepareEvolveService.selectPrepareEvolveById(prepareEvolveId);
//		String[] users = prepareEvolve.getPrepareList().split(",");
		String[] users = prepareEvolve.getExamineList().split(",");
		List<User> userList = new ArrayList<User>();//存放备案成员
		for(String userId : users){
			User u = userService.selectProposer(Long.parseLong(userId));
			userList.add(u);
		}
		System.out.println(userList.get(1));
		return getDataTable(userList);
	}
	
	/**
	 * 打开预审审核详情界面
	 */
	@RequiresPermissions("module:prepareEvolve:edit")
	@GetMapping("/examine/details")
	public String examineDetails(PrepareEvolve prepareEvolve, Model model){
		prepareEvolve = prepareEvolveService.selectPrepareEvolveById(prepareEvolve.getPrepareEvolveId());
		Conference c = conferenceService.selectConferenceById(prepareEvolve.getConferenceIdFirst());
		prepareEvolve.setConferenceFirst(c);
//		System.out.println(prepareEvolve.getExamineState()+"/////");
//		List<User> recordUserList = new ArrayList<User>();//存放备案名单
//		List<User> recordPassUserList = new ArrayList<User>();//存放备案通过名单
//		List<User> recordNotPassUserList = new ArrayList<User>();//存放备案未通过名单
//		User u = null;//用于开页展示
//		if(prepareEvolve.getExamineList() != null){
//			String[] userList = prepareEvolve.getExamineList().split(",");
//			u = userService.selectProposer(Long.parseLong(userList[0]));
//			for(String id : userList){
//				User user = userService.selectUserById(Long.parseLong(id));
//				recordUserList.add(user);
//			}
//		}
//		if(prepareEvolve.getExamineSuccess() != null){
//			String[] passList = prepareEvolve.getExamineSuccess().split(",");
//			for(String id : passList){
//				User user = userService.selectUserById(Long.parseLong(id));
//				recordPassUserList.add(user);
//			}
//		}else{
//			recordPassUserList = null;
//		}
//		if(prepareEvolve.getExamineFail() != null){
//			String[] notPassList = prepareEvolve.getExamineFail().split(",");
//			for(String id : notPassList){
//				User user = userService.selectUserById(Long.parseLong(id));
//				recordNotPassUserList.add(user);
//			}
//		}else{
//			recordNotPassUserList = null;
//		}
//		model.addAttribute("user", u);
//		model.addAttribute("recordUserList", recordUserList);
//		model.addAttribute("recordPassUserList", recordPassUserList);
//		model.addAttribute("recordNotPassUserList", recordNotPassUserList);
		model.addAttribute("prepareEvolve", prepareEvolve);
//		System.out.println(recordPassUserList);
//		System.out.println(recordNotPassUserList);
		return prefix + "/examineDetails_bak";
	}
	
	/**
	 * 打开上级预备党员预审管理界面
	 */
	@RequiresPermissions("module:prepareEvolve:view")
	@GetMapping("/examineRecordList")
	public String examineRecordList(Model model){
		//获取登陆用户判断管理员角色，若是支部管理员，则无权进行备案操作，只能等待备案
		User user = userService.selectProposer(ShiroUtils.getUserId());
		model.addAttribute("user", user);
		return prefix + "/examineRecordList";
	}
	
	/**
	 * 上级预审信息列表
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@PostMapping("/examine/lists")
	@ResponseBody
	public TableDataInfo examineLists(PrepareEvolve prepareEvolve){
		startPage();
		List<PrepareEvolve> pList = new ArrayList<PrepareEvolve>();//用于返回
		//根据登陆用户查询其部门及其子部门备案记录
		if(prepareEvolve.getDeptId() == null){
			prepareEvolve.setDeptId(ShiroUtils.getUserDeptId());
		}
		List<PrepareEvolve> list = prepareEvolveService.selectPrepareEvolveList(prepareEvolve);
		for(PrepareEvolve p : list){
			//查询备案会议，因为上面我们在Mybatis里只实现了查询一个会议，预备党员培养有两个会议。
			if(p.getConferenceIdSecond() != null){
				Conference c = conferenceService.selectConferenceById(p.getConferenceIdSecond());
				p.setConferenceSecond(c);
			}
			pList.add(p);
		}
		pList = idToNameList(pList);
		return getDataTable(pList);
	}
	
	/**
	 * 保存预备党员预审记录
	 */
	@RequiresPermissions("module:prepareEvolve:save")
	@Log(title = "预备党员预审记录", action = BusinessType.SAVE)
	@PostMapping("/saveExamine")
	@ResponseBody
	public AjaxResult saveExamine(@RequestParam(value = "file") MultipartFile file, PrepareEvolve prepareEvolve)
	{
		User user = ShiroUtils.getUser();
		if(upload(prepareEvolve, file, Constants.EXAMINE_ROSTER, 1)){
			prepareEvolve.setExamineRoster("/" + DateUtils.getDate() + "/" + prepareEvolve.getConferenceIdFirst() + "/" + file.getOriginalFilename());
		}
		prepareEvolve.setState(0);
		prepareEvolve.setExamineSubmitTime(DateUtils.getNowDate());
		prepareEvolve.setCreateBy(user.getUserName());
		prepareEvolve.setDeptId(ShiroUtils.getUserDeptId());
		prepareEvolve.setCreateTime(DateUtils.getNowDate());
		System.out.println(prepareEvolve);
		if (prepareEvolveService.insertPrepareEvolve(prepareEvolve) > 0)
		{
			//会议与发展记录id互绑
			Conference conference = conferenceService.selectConferenceById(prepareEvolve.getConferenceIdFirst());
			conference.setState(1);
			if(conferenceService.saveConference(conference) > 0){
				return success();
			}
		}
		return error();
	}
	
	/**
	 * 预备党员详情
	 */
	@RequiresPermissions("module:prepareEvolve:view")
	@GetMapping("/prepareDetails")
	public String prepareDetails(User user, Model model){
		user = userService.selectProposer(user.getUserId());
		model.addAttribute("user", user);
		return prefix + "/prepareDetails";
	}
	
	/**
	 * 查询发展预备党员记录列表
	 */
	@RequiresPermissions("module:prepareEvolve:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(User user)
	{
		startPage();
		//没部门筛选时,默认根据登录用户所在部门筛选
		if(user.getDeptId() == null){
			user.setDeptId(ShiroUtils.getUserDeptId());
		}
        List<User> list = userService.selectPrepareList(user);
		List<Role> roleList = new ArrayList<Role>();
		for(User u : list){
			roleList = roleService.selectRolesByUserId(u.getUserId());
			int i = 0;
			Long[] roles = new Long[10];
			for(Role role : roleList) {
				if(role.isFlag()){
					roles[i]=role.getRoleId();
					i++;
				}

			}
			u.setRoleIds(roles);
		}
		return getDataTable(list);
	}
	
	/**
	 * 新增发展预备党员记录
	 */
	@RequiresPermissions("module:prepareEvolve:add")
	@Log(title = "发展预备党员记录", action = BusinessType.INSERT)
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增发展预备预备预审记录
	 */
	@RequiresPermissions("module:prepareEvolve:add")
	@Log(title = "发展预备党员记录", action = BusinessType.INSERT)
	@GetMapping("/addExamine")
	public String addExamine()
	{
	    return prefix + "/addExamine";
	}

	/**
	 * 修改发展预备党员记录
	 */
	@RequiresPermissions("module:prepareEvolve:edit")
	@Log(title = "发展预备党员记录", action = BusinessType.UPDATE)
	@GetMapping("/edit/{prepareEvolveId}")
	public String edit(@PathVariable("prepareEvolveId") Integer prepareEvolveId, Model model)
	{
		PrepareEvolve prepareEvolve = prepareEvolveService.selectPrepareEvolveById(prepareEvolveId);
		model.addAttribute("prepareEvolve", prepareEvolve);
	    return prefix + "/edit";
	}
	
	/**
	 * 保存发展预备党员记录
	 */
	@RequiresPermissions("module:prepareEvolve:save")
	@Log(title = "发展预备党员记录", action = BusinessType.SAVE)
	@PostMapping("/save")
	@ResponseBody
	public AjaxResult save(@RequestParam(value = "file") MultipartFile file, PrepareEvolve prepareEvolve)
	{
		User user = ShiroUtils.getUser();
		if(upload(prepareEvolve, file, Constants.DEVELOPMENT_ROSTER, 2)){
			prepareEvolve.setPrepareRoster("/" + DateUtils.getDate() + "/" + prepareEvolve.getConferenceIdSecond() + "/" + file.getOriginalFilename());
		}
		prepareEvolve.setState(0);
		prepareEvolve.setSubmitTime(DateUtils.getNowDate());
		prepareEvolve.setUpdateBy(user.getUserName());
		prepareEvolve.setUpdateTime(DateUtils.getNowDate());
		System.out.println(prepareEvolve);
		if (prepareEvolveService.updatePrepareEvolve(prepareEvolve) > 0)
		{
			//会议与发展记录id互绑
			Conference conference = conferenceService.selectConferenceById(prepareEvolve.getConferenceIdSecond());
			conference.setState(1);
			if(conferenceService.saveConference(conference) > 0){
				return success();
			}
		}
		return error();
	}
	
	/**
	 * 删除发展预备党员记录
	 */
	@RequiresPermissions("module:prepareEvolve:remove")
	@Log(title = "发展预备党员记录", action = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{
		int rows = prepareEvolveService.deletePrepareEvolveByIds(ids);
		if (rows > 0)
        {
            return success();
        }
        return error();
	}
	
	/**
	 * 文件上传
	 */
	public boolean upload(PrepareEvolve prepareEvolve, MultipartFile file, String type, int count){
		boolean success = false;
		try {
			File document = null;
			String fileName = file.getOriginalFilename();  
			File firstFolder = new File(type);
			//判断是预审会议还是决议会议 1预审 2决议
			File secondFolder = null;
			if(count == 1){
				secondFolder = new File(firstFolder + "/" + DateUtils.getDate() + "/" + prepareEvolve.getConferenceIdFirst());
			}else if(count ==2){
				secondFolder = new File(firstFolder + "/" + DateUtils.getDate() + "/" + prepareEvolve.getConferenceIdSecond());
			}
			if(!firstFolder.exists()){
				firstFolder.mkdirs();
			}
			if(!secondFolder.exists()){
				secondFolder.mkdirs();
			}
			document = new File(secondFolder+"/",fileName);
			System.out.println("文件上传路径"+ document);
	        file.transferTo(document); 
	        success = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return success;
	}
	
	/**
	 * id集合转化name集合
	 */
	public List<PrepareEvolve> idToNameList(List<PrepareEvolve> list){
		for(PrepareEvolve c: list){
			String examineList = c.getExamineList();//获取预审名单
			String examineSuccessList = c.getSuccessList();
			String examineFailList = c.getFailList();
			String examineName = "";//存放预审姓名名单
			String examineSuccessName = "";//存放预审通过姓名名单
			String examineFailName = "";//存放预审未通过姓名名单
			
			String proposerList = c.getPrepareList();//获取备案名单
			String successList = c.getSuccessList();
			String failList = c.getFailList();
			String proposerName = "";//存放决议姓名名单
			String successName = "";//存放决议通过姓名名单
			String failName = "";//存放决议未通过姓名名单

			Conference conferenceFirst = conferenceService.selectConferenceById(c.getConferenceIdFirst());
			Conference conferenceSecond = conferenceService.selectConferenceById(c.getConferenceIdSecond());
			//获取相对应会议
			c.setConferenceFirst(conferenceFirst);
			if(conferenceSecond != null){
				c.setConferenceSecond(conferenceSecond);
			}
			//构造预审姓名名单
			if(examineList == null){
				c.setExamineNameList(null);
			}else{
				String[] pList = examineList.split(",");
				for(String id : pList){
					User user = userService.selectUserById(Long.valueOf(id));
					examineName += user.getUserName() + ",";
				}
				c.setExamineNameList(examineName.substring(0, examineName.length() - 2));
			}
			
			//构造预审未通过姓名名单
			if(examineFailList == null){
				c.setExamineFailNameList(null);
			}else{
				String[] fList = examineFailList.split(",");
				for(String id : fList){
					User user = userService.selectUserById(Long.valueOf(id));
					examineFailName += user.getUserName() + ",";
				}
				c.setFailNameList(examineFailName.substring(0, examineFailName.length() - 2));
			}
			
			//构造预审通过姓名名单
			if(examineSuccessList == null){
				c.setExamineSuccessNameList(null);
			}else{
				String[] sList = examineSuccessList.split(",");
				for(String id : sList){
					User user = userService.selectUserById(Long.valueOf(id));
					examineSuccessName += user.getUserName() + ",";
				}
				c.setExamineSuccessNameList(examineSuccessName.substring(0, examineSuccessName.length() - 2));
			}
			
			//构造决议姓名名单
			if(proposerList == null){
				c.setPrepareNameList(null);
			}else{
				String[] pList = proposerList.split(",");
				for(String id : pList){
					User user = userService.selectUserById(Long.valueOf(id));
					proposerName += user.getUserName() + ",";
				}
				c.setPrepareNameList(proposerName.substring(0, proposerName.length() - 2));
			}
			
			//构造未通过姓名名单
			if(failList == null){
				c.setFailNameList(null);
			}else{
				String[] fList = failList.split(",");
				for(String id : fList){
					User user = userService.selectUserById(Long.valueOf(id));
					failName += user.getUserName() + ",";
				}
				c.setFailNameList(failName.substring(0, failName.length() - 2));
			}
			
			//构造通过姓名名单
			if(successList == null){
				c.setSuccessNameList(null);
			}else{
				String[] sList = successList.split(",");
				for(String id : sList){
					User user = userService.selectUserById(Long.valueOf(id));
					successName += user.getUserName() + ",";
				}
				c.setSuccessNameList(successName.substring(0, successName.length() - 2));
			}
			
		}
		return list;
	}
}
